package com.woniu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.mapper.RoadMapper;
import com.woniu.pojo.Road;
import com.woniu.service.RoadService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.entity.PageData;
import com.woniu.entity.dto.QueryRoadDTO;
import com.woniu.entity.vo.RoadVo;
import com.woniu.mapper.RoadMapper;
import com.woniu.pojo.Inspector;
import com.woniu.pojo.Road;
import com.woniu.service.RoadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author Ma.Lei
* @description 针对表【t_road】的数据库操作Service实现
* @createDate 2022-12-16 23:28:20
*/
@Service
public class RoadServiceImpl extends ServiceImpl<RoadMapper, Road>
    implements RoadService {
    @Autowired
    private RoadMapper roadMapper;

    @Override
    public String getIdByName(String roadName) {
        String id = roadMapper.getIdByName(roadName);
        return id;
    }


    @Override
    public PageData listSearch(Integer currentPage, Integer pageSize, QueryRoadDTO queryRoadDTO) {

        // 2. 构建分页参数
        IPage<RoadVo> page = new Page<>(currentPage, pageSize);
        // 3. roadMapper
        IPage<RoadVo> roadVoIPage = roadMapper.selectPageRoad(page,queryRoadDTO);
        // 4. 组装返回数据对象
        PageData pageData = new PageData(roadVoIPage.getTotal(), roadVoIPage.getRecords());
        // 5. 返回数据
        return pageData;
    }

    @Override
    public Inspector getByInspectorName(String id) {
        return roadMapper.getByInspectorName(id);
    }
}




